***********************************************
***** Pandora's Rules in the Laboratory  ******
***********************************************


** Run this file to replicate the findings shown in Tables 3, 6, and 9.
** Input files: T3_6_9.dta. This file is generated using Main.dta.
** After executing the commands below, we rounded and trasferred the results into the relevant Tables. 


** Change working directory 
cd "...."


use "Main.dta", clear

preserve
collapse openfirst, by(treatment Session Subject)
keep if treatment == 0
keep openfirst
rename openfirst openfirstfullt0
save b1.dta, replace
restore 

preserve
collapse openfirst, by(treatment Session Subject)
keep if treatment == 1
keep openfirst
rename openfirst openfirstfullt1
save b2.dta, replace
restore 


preserve
keep if Period>50
collapse openfirst, by(treatment Session Subject)
keep if treatment == 0
keep openfirst
rename openfirst openfirsthalft0
save b3.dta, replace
restore 

preserve
keep if Period>50
collapse openfirst, by(treatment Session Subject)
keep if treatment == 1
keep openfirst
rename openfirst openfirsthalft1
save b4.dta, replace
restore 


preserve
collapse correct1_r0, by(treatment Session Subject)
keep if treatment == 0
keep correct1_r0
rename correct1_r0 correct1_r0fullt0
save c1.dta, replace
restore 

preserve
collapse correct1_r0, by(treatment Session Subject)
keep if treatment == 1
keep correct1_r0
rename correct1_r0 correct1_r0fullt1
save c2.dta, replace
restore 


preserve
keep if Period>50
collapse correct1_r0, by(treatment Session Subject)
keep if treatment == 0
keep correct1_r0
rename correct1_r0 correct1_r0halft0
save c3.dta, replace
restore 

preserve
keep if Period>50
collapse correct1_r0, by(treatment Session Subject)
keep if treatment == 1
keep correct1_r0
rename correct1_r0 correct1_r0halft1
save c4.dta, replace
restore 


preserve
collapse correct2_r0, by(treatment Session Subject)
keep if treatment == 0
keep correct2_r0
rename correct2_r0 correct2_r0fullt0
save d1.dta, replace
restore 

preserve
collapse correct2_r0, by(treatment Session Subject)
keep if treatment == 1
keep correct2_r0
rename correct2_r0 correct2_r0fullt1
save d2.dta, replace
restore 


preserve
keep if Period>50
collapse correct2_r0, by(treatment Session Subject)
keep if treatment == 0
keep correct2_r0
rename correct2_r0 correct2_r0halft0
save d3.dta, replace
restore 

preserve
keep if Period>50
collapse correct2_r0, by(treatment Session Subject)
keep if treatment == 1
keep correct2_r0
rename correct2_r0 correct2_r0halft1
save d4.dta, replace
restore 





preserve
collapse Payoff, by(treatment Session Subject)
keep if treatment == 0
keep Payoff
rename Payoff Payoffullt0
save e1.dta, replace
restore 

preserve
collapse Payoff, by(treatment Session Subject)
keep if treatment == 1
keep Payoff
rename Payoff Payoffullt1
save e2.dta, replace
restore 


preserve
keep if Period>50
collapse Payoff, by(treatment Session Subject)
keep if treatment == 0
keep Payoff
rename Payoff Payoffhalft0
save e3.dta, replace
restore 

preserve
keep if Period>50
collapse Payoff, by(treatment Session Subject)
keep if treatment == 1
keep Payoff
rename Payoff Payoffhalft1
save e4.dta, replace
restore 


clear all
use b1.dta, clear
merge 1:1 _n using "b2.dta", nogenerate
merge 1:1 _n using "b3.dta", nogenerate
merge 1:1 _n using "b4.dta", nogenerate

merge 1:1 _n using "c1.dta", nogenerate
merge 1:1 _n using "c2.dta", nogenerate
merge 1:1 _n using "c3.dta", nogenerate
merge 1:1 _n using "c4.dta", nogenerate


merge 1:1 _n using "d1.dta", nogenerate
merge 1:1 _n using "d2.dta", nogenerate
merge 1:1 _n using "d3.dta", nogenerate
merge 1:1 _n using "d4.dta", nogenerate

merge 1:1 _n using "e1.dta", nogenerate
merge 1:1 _n using "e2.dta", nogenerate
merge 1:1 _n using "e3.dta", nogenerate
merge 1:1 _n using "e4.dta", nogenerate


save "T3_6_9.dta", replace

use "T3_6_9.dta", clear


*************
** Table 3 **
*************

ttest    openfirstfullt1 = openfirstfullt0
ttest    openfirsthalft1 = openfirsthalft0

signrank openfirstfullt1 = openfirstfullt0
signrank openfirsthalft1 = openfirsthalft0

signtest openfirstfullt0 = openfirstfullt1
signtest openfirsthalft0 = openfirsthalft1

*************
** Table 6 **
*************

*First Move
ttest    correct1_r0fullt0 = correct1_r0fullt1 
ttest    correct1_r0halft0 = correct1_r0halft1

signrank correct1_r0fullt0 = correct1_r0fullt1 
signrank correct1_r0halft0 = correct1_r0halft1

signtest correct1_r0fullt0 = correct1_r0fullt1 
signtest correct1_r0halft0 = correct1_r0halft1


*All Moves
ttest    correct2_r0fullt0 = correct2_r0fullt1 
ttest    correct2_r0halft0 = correct2_r0halft1

signrank correct2_r0fullt0 = correct2_r0fullt1 
signrank correct2_r0halft0 = correct2_r0halft1

signtest correct2_r0fullt0 = correct2_r0fullt1 
signtest correct2_r0halft0 = correct2_r0halft1



**************
** Table 9 **
**************

ttest    Payoffullt0  = Payoffullt1
ttest    Payoffhalft0 = Payoffhalft1

signrank Payoffullt0  = Payoffullt1
signrank Payoffhalft0 = Payoffhalft1

signtest Payoffullt0  = Payoffullt1
signtest Payoffhalft0 = Payoffhalft1



***** end of Do file *****






